<template>
    <div>
      <el-form :model="formData" ref="formData" :rules="formRules" label-position="left" class="form-data">
        <el-form-item label="申请类型" >{{status == '1' ? '房东' : '经纪人'}}</el-form-item>
        <el-form-item label="真实姓名" >{{entity.name}}</el-form-item>
        <el-form-item label="手机号" >{{entity.phone}}</el-form-item>
        <el-form-item label="身份类型" >{{entity.typeString}}</el-form-item>
        <!--<el-form-item label="身份证号" >{{entity.cardId}}</el-form-item>-->
        <!--<el-form-item label="身份证国徽面" prop="title">-->
          <!--<el-image :src="entity.cardPhotoBack" style="width: 100%; height: 150px;"></el-image>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="身份证人像面" >-->
          <!--<el-image :src="entity.cardPhotoJust" style="width: 100%; height: 150px;"></el-image>-->
        <!--</el-form-item>-->
        <el-form-item label="审核" prop="authentication" v-if="entity.authentication == 0">
          <el-radio-group v-model="formData.authentication">
            <el-radio :label="1">通 过</el-radio>
            <el-radio :label="2">驳 回</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="驳回原因" prop="authentication" v-if="entity.authentication == 2">
          {{entity.rejectReason}}
        </el-form-item>
        <el-form-item label="驳回原因" prop="rejectReason" v-if="formData.authentication == 2">
          <el-input v-model="formData.rejectReason" type="textarea" :autosize="{ minRows: 10 }" placeholder="请输入驳回原因"></el-input>
        </el-form-item>
        <el-form-item class="form-button" v-if="entity.authentication == 0">
          <el-button class="but-view" @click="drawerClose">取 消</el-button>
          <el-button class="but-view" type="primary" @click="onSubmit">提 交</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>

<script>
  export default {
    name: 'AuditForm',
    props: {
      entity: Object,
      status: String
    },
    data() {
      return {
        formData: {
          authentication: 1,
          rejectReason: null,
        },
        formRules: {
          rejectReason: [
            { required: true, message: '请输入驳回理由', trigger: 'blur' }
          ],
          authentication: [
            { required: true, message: '请选择审核状态', trigger: 'change' }
          ]
        }
      }
    },
    methods: {
      drawerClose () {
        this.$emit('close')
      },
      async onSubmit () {
        const url = this.status == 2 ? '/my/house/agent/backstage/update' : '/my/house/master/backstage/update'
        await this.$ajax.post(url, {
          "authentication": this.formData.authentication,
          "id": this.entity.id,
          "rejectReason": this.formData.rejectReason,
          "userId": this.entity.userId
        })
        this.$message.success('操作成功!')
        this.$emit('refresh')
        this.drawerClose()
      },
    }
  }
</script>

<style scoped>

</style>
